From: Colin Walters Date: Sat, 27 Aug 2016 12:50:47 +0000 (-0400) Subject: sysroot: Drop unnecessary `dup()` invocation X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~48^2~8 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=cfc3934e81bd1cd083f089c9711d1324b2612c9f;p=ostree.git sysroot: Drop unnecessary `dup()` invocation It's close-on-exec, not close-on-fork. I was clearly confused when writing this; it works just fine to reference the fd in the child and `fchdir()` before exec. So drop the unnecessary duplication. Just noticed this while reading the code for a random other reason. Closes: #473 Approved by: giuseppe --- diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 2a55c6b1..227fdd24 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -1776,17 +1776,6 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self, * threads, etc. */ { - /* Make a copy of the fd that's *not* FD_CLOEXEC so that we pass - * it to the child. - */ - glnx_fd_close int child_deployment_dfd = dup (deployment_dfd); - - if (child_deployment_dfd < 0) - { - glnx_set_error_from_errno (error); - goto out; - } - mount_child = fork (); if (mount_child < 0) { @@ -1796,9 +1785,8 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self, else if (mount_child == 0) { /* Child process. Do NOT use any GLib API here. */ - if (fchdir (child_deployment_dfd) < 0) + if (fchdir (deployment_dfd) < 0) exit (EXIT_FAILURE); - (void) close (child_deployment_dfd); if (mount ("overlay", "/usr", "overlay", 0, ovl_options) < 0) exit (EXIT_FAILURE); exit (EXIT_SUCCESS);